package com.csj.mvvm.utils

import android.util.Log
import com.csj.mvvm.App
import com.csj.mvvm.R

object LogUtil {
    private val TAG = App.instance.getString(R.string.log_tag)
    private val TAG_NET = App.instance.getString(R.string.log_tag_net)
    //app->buildTypes->release/debug 配置 resValue "bool", "log_debug", 'true'
    private val DEBUG = App.instance.resources.getBoolean(R.bool.log_debug)

    fun i(message: String?) {
        if (DEBUG) message?.let { Log.i(TAG, message) }
    }

    @JvmStatic
    fun d(message: String?) {
        if (DEBUG) message?.let { Log.d(TAG, message) }
    }

    @JvmStatic
    fun e(message: String?) {
        if (DEBUG) message?.let { Log.e(TAG, message) }
    }

    fun i(message: String?, tag: String) {
        if (DEBUG) message?.let { Log.i(tag, message) }
    }

    @JvmStatic
    fun d(message: String?, tag: String) {
        if (DEBUG) message?.let { Log.d(tag, message) }
    }

    @JvmStatic
    fun e(message: String?, tag: String) {
        if (DEBUG) message?.let { Log.e(tag, message) }
    }

    fun showHttpHeaderLog(message: String?) {
        if (DEBUG) message?.let { Log.d(TAG_NET, message) }
    }

    fun showHttpApiLog(message: String?) {
        if (DEBUG) message?.let { Log.w(TAG_NET, message) }
    }

    fun showHttpLog(message: String?) {
        if (DEBUG) message?.let { Log.i(TAG_NET, message) }
    }
}